<template>
	<div class="page-wrap">
		<div class="page-content p-0">
			<div class="page-column p-0">
				<div class="page-form p-x-0">
					<el-form
						:model="ruleForm"
						:rules="rules"
						label-position="left"
						label-width="154px"
						ref="form"
						label-suffix="："
					>
						<el-row>
							<el-col :span="24">
								<div class="my_title m-b-20">事故发生一年内，牛奶最大允许摄入剂量</div>
								<el-form-item label="有效剂量阈值" prop="DOSEMILK_EFF">
									<el-input
										size="medium"
										class="mediumForm"
										oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,10})?).*$/g, '$1')"
										v-model="ruleForm.DOSEMILK_EFF"
									>
										<template slot="append">sv</template>
									</el-input>
								</el-form-item>
								<el-form-item label="甲状腺剂量阈值" prop="DOSEMILK_THY">
									<el-input
										size="medium"
										class="mediumForm"
										oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,10})?).*$/g, '$1')"
										v-model="ruleForm.DOSEMILK_THY"
									>
										<template slot="append">sv</template>
									</el-input>
								</el-form-item>
								<div class="my_title m-b-20">事故发生一年内，非牛奶作物最大允许摄入剂量</div>
								<el-form-item label="有效剂量阈值" prop="DOSEOTHER_EFF">
									<el-input
										size="medium"
										class="mediumForm"
										oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,10})?).*$/g, '$1')"
										v-model="ruleForm.DOSEOTHER_EFF"
									>
										<template slot="append">sv</template>
									</el-input>
								</el-form-item>
								<el-form-item label="甲状腺剂量阈值" prop="DOSEOTHER_THY">
									<el-input
										size="medium"
										class="mediumForm"
										oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,10})?).*$/g, '$1')"
										v-model="ruleForm.DOSEOTHER_THY"
									>
										<template slot="append">sv</template>
									</el-input>
								</el-form-item>
								<div class="my_title m-b-20">事故发生一年内，最大长期允许摄入剂量</div>
								<el-form-item label="有效剂量阈值" prop="DOSELONG_EFF">
									<el-input
										size="medium"
										class="mediumForm"
										oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,10})?).*$/g, '$1')"
										v-model="ruleForm.DOSELONG_EFF"
									>
										<template slot="append">sv</template>
									</el-input>
								</el-form-item>
								<el-form-item label="甲状腺剂量阈值" prop="DOSELONG_THY">
									<el-input
										size="medium"
										class="mediumForm"
										oninput="value=value.replace(/^\D*(\d*(?:\.\d{0,10})?).*$/g, '$1')"
										v-model="ruleForm.DOSELONG_THY"
									>
										<template slot="append">sv</template>
									</el-input>
								</el-form-item>
							</el-col>
						</el-row>
					</el-form>
				</div>
				<div class="bottom-btn">
					<el-button
						type="primary"
						:disabled="this.basic_Data.OCENDAT1001=='TRUE' ||this.early_Data.MIENDAT2001=='TRUE'"
						:loading="loading"
						@click="submitFun"
					>下一步</el-button>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
import selectPara from "@/components/selectPara"
import commCheckbox from "@/components/commCheckbox"
import ImageCropper from "@/components/ImageCropper"
import FixBottomButton from "@/components/FixBottomButton"
import ueditor from "@/components/ueditor"
import textLength from "@/components/common/comp/textLength"
import { commPara } from "@/mixins/mixins"
import { mapState } from "vuex"
export default {
	name: "aboutUs",
	props: {},
	mixins: [commPara],
	components: {
		selectPara,
		ImageCropper,
		textLength,
		commCheckbox,
		FixBottomButton,
		ueditor,
	},

	data() {
		var C001010 = (rule, value, callback) => {
			if (value == "") {
				callback(new Error("输入值不能为空"))
			} else if (value < 0.0 || value > 1.0e10) {
				callback(new Error("输入范围为[0.0,1.0E+10]"))
			} else {
				callback()
			}
		}

		return {
			activeTab: "6", 
			ruleForm: {
				DOSEMILK_EFF: "0.25",
				DOSEMILK_THY: "0.75",
				DOSEOTHER_EFF: "0.25",
				DOSEOTHER_THY: "0.75",
				DOSELONG_EFF: "0.25",
				DOSELONG_THY: "0.75",
			},
			rules: {
				DOSEMILK_EFF: [
					{
						validator: C001010,
						trigger: ["change", "blur"],
					},
				],
				DOSEMILK_THY: [
					{
						validator: C001010,
						trigger: ["change", "blur"],
					},
				],
				DOSEOTHER_EFF: [
					{
						validator: C001010,
						trigger: ["change", "blur"],
					},
				],
				DOSEOTHER_THY: [
					{
						validator: C001010,
						trigger: ["change", "blur"],
					},
				],
				DOSELONG_EFF: [
					{
						validator: C001010,
						trigger: ["change", "blur"],
					},
				],
				DOSELONG_THY: [
					{
						validator: C001010,
						trigger: ["change", "blur"],
					},
				],
			},

			loading: false,
		}
	},

	computed: {
		...mapState({
			basic_Data: (state) => state.token.basic_Data,
			early_Data: (state) => state.token.early_Data,
			longterm_Data: (state) => state.token.longterm_Data,
		}),
	},
	mounted() {
		this.setData()
	},
	methods: {
		setData() {
			this.ruleForm.DOSEMILK_EFF = this.longterm_Data.DOSEMILK_EFF
				? this.longterm_Data.DOSEMILK_EFF.toString()
				: "0.025"
			this.ruleForm.DOSEMILK_THY = this.longterm_Data.DOSEMILK_THY
				? this.longterm_Data.DOSEMILK_THY.toString()
				: "0.075"
			this.ruleForm.DOSEOTHER_EFF = this.longterm_Data.DOSEOTHER_EFF
				? this.longterm_Data.DOSEOTHER_EFF.toString()
				: "0.025"
			this.ruleForm.DOSEOTHER_THY = this.longterm_Data.DOSEOTHER_THY
				? this.longterm_Data.DOSEOTHER_THY.toString()
				: '0.075'
			this.ruleForm.DOSELONG_EFF = this.longterm_Data.DOSELONG_EFF
				? this.longterm_Data.DOSELONG_EFF.toString()
				: '0.025'
			this.ruleForm.DOSELONG_THY = this.longterm_Data.DOSELONG_THY
				? this.longterm_Data.DOSELONG_THY.toString()
				: "0.075"
		},
		submitFun() {
			//保存
			this.$refs.form.validate((valid) => {
				if (valid) { 
					let tempdata = JSON.parse(
						JSON.stringify(this.longterm_Data)
					)
					tempdata.DOSEMILK_EFF = parseFloat(
						this.ruleForm.DOSEMILK_EFF
					)
					tempdata.DOSEMILK_THY = parseFloat(
						this.ruleForm.DOSEMILK_THY
					)
					tempdata.DOSEOTHER_EFF = parseFloat(
						this.ruleForm.DOSEOTHER_EFF
					)
					tempdata.DOSEOTHER_THY = parseFloat(
						this.ruleForm.DOSEOTHER_THY
					)

					tempdata.DOSELONG_EFF = parseFloat(
						this.ruleForm.DOSELONG_EFF
					)
					tempdata.DOSELONG_THY = parseFloat(
						this.ruleForm.DOSELONG_THY
					)
					tempdata.SETPAGEINDEX = this.activeTab
					this.$store.dispatch("upData_longterm_Data", tempdata) 
					let params = {
						batchid: this.$route.query.id,
						batchinfo: "CHANGQI",
						submitjson: JSON.stringify(tempdata),
					} 
					this.$appApi
						.BATCH_SUBMIT(params)
						.then((res) => { 
							var str = res.data.substring(0, 1)
							if (str == "E") {
								let message = res.data.substring(6)
								this.$notify.error({
									title: "保存失败！",
									message: message,
									type: "success",
								})
							} else if (str == "S") {
								this.$notify({
									message: "保存成功！",
									type: "success",
								})
							}
						})
						.catch((err) => {
							console.log(err)
						})
					this.$emit("changeActiveTab", this.activeTab)
					this.$store.dispatch(
						"change_longterm_showTab",
						this.activeTab
					)
				}
			})
		},
		daochu() {
			//导出
		},
	},
}
</script>
<style lang="scss" scoped>
.page-flex-row /deep/ .el-collapse-item__header {
	background: #f3f9fe;
}
</style>